home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / svgabg55 / initsvga.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-06-10  |  5.7 KB  |  240 lines

  1. { Sample program that initializes the SuperVGA driver}
  2. Program Test256;
  3.  
  4. Uses Graph,Crt,Dos;
  5.  
  6. {$i svga16.inc}
  7. {$i svga256.inc}
  8. {$i svga32k.inc}
  9. {$i svga64k.inc}
  10. {$i svgatc.inc}
  11. {$i svgas3.inc}
  12. {$i twk16.inc}
  13. {$i twk256.inc}
  14. {$i svgautil.inc}
  15.  
  16. (* Uncomment this if you link in the drivers *)
  17. (*
  18. procedure Svga16_driver; external;
  19. { $L svga16.obj }
  20.  
  21. procedure Svga256_driver; external;
  22. { $L svga256.obj }
  23.  
  24. procedure Twk256_driver; external;
  25. { $L twk256.obj }
  26.  
  27. procedure Twk16_driver; external;
  28. { $L twk16.obj }
  29.  
  30. procedure Svga32k_driver; external;
  31. { $L svga32k.obj }
  32.  
  33. procedure Svga64k_driver; external;
  34. { $L svga64k.obj }
  35.  
  36. procedure SvgaTC_driver; external;
  37. { $L svgatc.obj }
  38.  
  39. procedure SvgaS3_driver; external;
  40. { $L svgas3.obj }
  41. *)
  42.  
  43. var
  44.   GraphMode, GraphDriver, GrErr : integer;
  45.   Ky : Char;
  46.   Drv : Integer;
  47.  
  48. function WhitePixel : Word;
  49. begin
  50.   if (GetMaxColor > 256) then
  51.     WhitePixel := 32767
  52.   else
  53.     WhitePixel := 15;
  54. end;
  55.  
  56. {$F+}
  57. function DetectVGA256 : Integer;
  58. var Vid : Integer;
  59.  
  60. begin
  61.   Writeln('Which video mode would you like to use?');
  62.   Writeln('  0) 320x200x256');
  63.   Writeln('  1) 640x400x256');
  64.   Writeln('  2) 640x480x256');
  65.   Writeln('  3) 800x600x256');
  66.   Writeln('  4) 1024x768x256');
  67.   Writeln('  5) 640x350x256');
  68.   Writeln('  6) 1280x1024x256');
  69.   Write('> ');
  70.   Readln(Vid);
  71.   DetectVGA256 := Vid;
  72. end;
  73.  
  74. function DetectS3 : Integer;
  75. var Vid : Integer;
  76.  
  77. begin
  78.   Writeln('Which video mode would you like to use?');
  79.   Writeln('  0) 640x480x256');
  80.   Writeln('  1) 800x600x256');
  81.   Writeln('  2) 1024x768x256');
  82.   Writeln('  3) 800x600x16');
  83.   Writeln('  4) 1024x768x16');
  84.   Writeln('  5) 1280x960x16');
  85.   Writeln('  6) 1280x1024x16');
  86.   Writeln('  7) 640x480x32768');
  87.   Write('> ');
  88.   Readln(Vid);
  89.   DetectS3 := Vid;
  90. end;
  91.  
  92. function DetectVGATC : Integer;
  93. var Vid : Integer;
  94.  
  95. begin
  96.   Writeln('Which video mode would you like to use?');
  97.   Writeln('  0) 320x200x24-bit');
  98.   Writeln('  1) 640x350x24-bit');
  99.   Writeln('  2) 640x400x24-bit');
  100.   Writeln('  3) 640x480x24-bit');
  101.   Writeln('  4) 800x600x24-bit');
  102.   Writeln('  5) 1024x768x24-bit');
  103.   Writeln('  6) 1280x1024x24-bit');
  104.   Write('> ');
  105.   Readln(Vid);
  106.   DetectVGATC := Vid;
  107. end;
  108.  
  109. function DetectVGA64k : Integer;
  110. var Vid : Integer;
  111.  
  112. begin
  113.   Writeln('Which video mode would you like to use?');
  114.   Writeln('  0) 320x200x65536');
  115.   Writeln('  1) 640x350x65536');
  116.   Writeln('  2) 640x400x65536');
  117.   Writeln('  3) 640x480x65536');
  118.   Writeln('  4) 800x600x65536');
  119.   Writeln('  5) 1024x768x65536');
  120.   Writeln('  6) 1280x1024x65536');
  121.   Write('> ');
  122.   Readln(Vid);
  123.   DetectVGA64k := Vid;
  124. end;
  125.  
  126. function DetectVGA32k : Integer;
  127. var Vid : Integer;
  128.  
  129. begin
  130.   Writeln('Which video mode would you like to use?');
  131.   Writeln('  0) 320x200x32768');
  132.   Writeln('  1) 640x350x32768');
  133.   Writeln('  2) 640x400x32768');
  134.   Writeln('  3) 640x480x32768');
  135.   Writeln('  4) 800x600x32768');
  136.   Writeln('  5) 1024x768x32768');
  137.   Writeln('  6) 1280x1024x32768');
  138.   Write('> ');
  139.   Readln(Vid);
  140.   DetectVGA32k := Vid;
  141. end;
  142.  
  143. function DetectVGA16 : Integer;
  144. var Vid : Integer;
  145.  
  146. begin
  147.   Writeln('Which video mode would you like to use? ');
  148.   Writeln('  0) 320x200x16');
  149.   Writeln('  1) 640x200x16');
  150.   Writeln('  2) 640x350x16');
  151.   Writeln('  3) 640x480x256');
  152.   Writeln('  4) 800x600x16');
  153.   Writeln('  5) 1024x768x16');
  154.   Writeln('  6) 1280x1024x16');
  155.   Writeln('>');
  156.   Readln(Vid);
  157.   DetectVGA16 := Vid;
  158. end;
  159.  
  160. function DetectTwk256 : Integer;
  161. var Vid : Integer;
  162.  
  163. begin
  164.   Writeln('Which video mode would you like to use?');
  165.   Writeln('  0) 320x400x256');
  166.   Writeln('  1) 320x480x256');
  167.   Writeln('  2) 360x480x256');
  168.   Writeln('  3) 376x564x256');
  169.   Writeln('  4) 400x564x256');
  170.   Writeln('  5) 400x600x256');
  171.   Writeln('  6) 320x240x256');
  172.   Write('> ');
  173.   Readln(Vid);
  174.   DetectTwk256 := Vid;
  175. end;
  176.  
  177. function DetectTwk16 : Integer;
  178. var Vid : Integer;
  179.  
  180. begin
  181.   Writeln('Which video mode would you like to use? ');
  182.   Writeln('  0) 704x528x16');
  183.   Writeln('  1) 720x540x16');
  184.   Writeln('  2) 736x552x16');
  185.   Writeln('  3) 752x564x256');
  186.   Writeln('  4) 768x576x16');
  187.   Writeln('  5) 784x588x16');
  188.   Writeln('  6) 800x600x16');
  189.   Writeln('>');
  190.   Readln(Vid);
  191.   DetectTwk16 := Vid;
  192. end;
  193. {$F-}
  194.  
  195. begin
  196.   Writeln('Which driver would you like to use?');
  197.   Writeln('  0) Svga16');
  198.   Writeln('  1) Svga256');
  199.   Writeln('  2) Svga32k');
  200.   Writeln('  3) Svga64k');
  201.   Writeln('  4) SvgaTC');
  202.   Writeln('  5) SvgaS3');
  203.   Writeln('  6) Tweak256');
  204.   Writeln('  7) Tweak16');
  205.   Write('>');
  206.   Readln(Drv);
  207.   if (Drv = 0) then
  208.     GraphDriver := InstallUserDriver('SVGA16',@DetectVGA16)
  209.   else if (Drv = 1) then
  210.     GraphDriver := InstallUserDriver('SVGA256',@DetectVGA256)
  211.   else if (Drv = 2) then
  212.     GraphDriver := InstallUserDriver('Svga32k',@DetectVGA32k)
  213.   else if (Drv = 3) then
  214.     GraphDriver := InstallUserDriver('Svga64k',@DetectVGA64k)
  215.   else if (Drv = 4) then
  216.     GraphDriver := InstallUserDriver('SvgaTC',@DetectVGATC)
  217.   else if (Drv = 5) then
  218.     GraphDriver := InstallUserDriver('SvgaS3',@DetectS3)
  219.   else if (Drv = 6) then
  220.     GraphDriver := InstallUserDriver('Twk256',@DetectTwk256)
  221.   else if (Drv = 7) then
  222.     GraphDriver := InstallUserDriver('Twk16',@DetectTwk16);
  223.   GraphDriver := Detect;
  224.   InitGraph(GraphDriver,GraphMode,'');
  225.   GrErr := GraphResult;             { preserve error return }
  226.   if GrErr AND $80 = $80 then
  227.      GrErr := GrErr OR $ff00;
  228.   if GrErr <> grOK then             { error? }
  229.   begin
  230.     Writeln('Graphics error: ', GraphErrorMsg(GrErr));
  231.     Halt(1);
  232.   end;
  233.  
  234.   setcolor(RealDrawColor(WhitePixel));
  235.   line(0,0,GetMaxX,GetMaxY);
  236.   line(0,GetMaxY,GetMaxX,0);
  237.   Ky := ReadKey;
  238.   CloseGraph;
  239. end.
  240.